package jlxy.ise.cloudcourse.controller;

import java.util.List;
import java.util.Map;
import jlxy.ise.cloudcourse.service.SampleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * @author yecq
 */
@RestController
public class SampleController {

    @Autowired
    private SampleService ss;

    @RequestMapping("/list-users")
    public List do_listUsers() {
        return this.ss.listUsers();
    }

    @RequestMapping("/get-user")
    public Map do_getUser(@RequestParam("name") String name) {
        return this.ss.getUser(name);
    }

    @RequestMapping("add-user")
    public void do_addUser(@RequestParam("name") String name, @RequestParam("age") int age) {
        this.ss.addUser(name, age);
    }

    @RequestMapping("remove-user")
    public void do_removeUser(@RequestParam("id") String id) {
        this.ss.removeUser(id);
    }

    @RequestMapping("modify-user")
    public void do_modifyUser(@RequestParam("id") String id, @RequestParam("name") String name, @RequestParam("age") int age) {
        this.ss.modifyUser(id, name, age);
    }
}
